package com.nbclass.modules.news.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nbclass.common.util.StringUtils;
import com.nbclass.modules.news.mapper.NewsArticleMapper;
import com.nbclass.modules.news.model.NewsArticle;
import com.nbclass.modules.news.service.INewsArticleService;

/**
 * 新闻文章表 服务实现类
 */
@Service
public class NewsArticleServiceImpl extends ServiceImpl<NewsArticleMapper, NewsArticle> implements INewsArticleService {

	@Autowired
	private NewsArticleMapper newsArticleMapper;
	
	
	@Override
	public List<NewsArticle> listNewsArticle(NewsArticle newsArticle) {
		QueryWrapper<NewsArticle> queryWrapper = new QueryWrapper<NewsArticle>();
		if (StringUtils.isNotEmpty(newsArticle.getTitle())) {
			queryWrapper.like("title", newsArticle.getTitle());
		}
		if (newsArticle.getSetTop() != null) {
			queryWrapper.eq("setTop", newsArticle.getSetTop());
		}
		if (newsArticle.getStatus() != null) {
			queryWrapper.eq("status", newsArticle.getStatus());
		}
		return newsArticleMapper.selectList(queryWrapper);
	}

}
